<?php
namespace Core\CoreContracts;
/*
* Operation definition class definition
*
* @method Create($accountId, $label, $type, $status, $paymentMean, $category, $expectedamount, $operationdate, $isRecurring)
* @method GetOppositeOperation()
*/
class Operation {

	/*
	* @property integer $Id The operation unique identifier
	*/
	public $Id;
	
	/*
	* @property Account $Account The associated account
	*/
	public $Account;
	
	/*
	* @property string $Label The operation description
	*/
	public $Label;
	
	/*
	* @property integer $Type The operation type
	*/
	public $Type;
	
	/*
	* @property integer $Type The operation state
	*/
	public $Status;
	
	/*
	* @property Category $Category The associated category
	*/
	public $Category;
	
	/*
	* @property integer $PaymentMean The payment mean
	*/
	public $PaymentMean;
	
	/*
	* @property float $Expectedamount The expected amount
	*/
	public $Expectedamount;
	
	/*
	* @property float $Realamount The real amount
	*/
	public $Realamount;
	
	/*
	* @property datetime $Operationdate The operation date
	*/
	public $Operationdate;
	
	/*
	* @property boolean $IsRecurring Is operation recurring
	*/
	public $IsRecurring;
	
	/*
	* @property string $BillMime The bill's mime
	*/
	public $BillMime;
	
	/*
	* @property string $BillExtension The bill's extension
	*/
	public $BillExtension;
	
	/*
	* @property blob $Bill The bill binary data
	*/
	public $Bill;
	
	/*
	* @property datetime $ModificationDate The operation modification date
	*/
	public $ModificationDate;
	
	/*
	* @property datetime $ModificationDate The operation creation date
	*/
	public $CreationDate;
	
	/**
	* The default constructor
	*/
	public function __construct()  {  }
	
	/*
	* Build a new operation object
	*
	* @param integer $accountId The account id
	* @param string $label The operation label
	* @param integer $type The operation type
	* @param integer $status The operation state
	* @param integer $paymentMean The operation payment mean
	* @param Category $category The operation category
	* @param float $expectedamount The expected amount
	* @param datetime $operationdate The operation date
	* @param boolean $isRecurring Is operation recurring
	*/
	public static function Create($accountId, $label, $type, $status, $paymentMean, $category, $expectedamount, $operationdate, $isRecurring)
	{
		$operation = new Operation();
		$operation->Account = $accountId;
		$operation->Label = $label;
		$operation->Type = $type;
		$operation->Status = $status;
		$operation->PaymentMean = $paymentMean;
		$operation->Category = $category;
		$operation->Expectedamount = $expectedamount;
		$operation->Realamount = 0;
		$operation->Operationdate = $operationdate;
		$operation->IsRecurring = $isRecurring;
		$operation->ModificationDate = date("Y-m-d H:i:s");
		$operation->CreationDate = date("Y-m-d H:i:s");
		return $operation;
	}
	
	/*
	* Get inverse operation, in case of a rejected operation
	*/
	public function GetOppositeOperation()
	{
		$operation = new Operation();
		$operation->Account = $this->Account;
		$operation->Label = $this->Label;
		$operation->Type = ($this->Type == 0) ? 1 : 0;
		$operation->Status = $this->Status;
		$operation->PaymentMean = $this->PaymentMean;
		$operation->Category = $this->Category;
		$operation->Expectedamount = $this->Expectedamount;
		$operation->Realamount = $this->Realamount;
		$operation->Operationdate = $this->Operationdate;
		$operation->IsRecurring = $this->IsRecurring;
		$operation->ModificationDate = date("Y-m-d H:i:s");
		$operation->CreationDate = date("Y-m-d H:i:s");
		return $operation;
	}
}
?> 